R, Rstudio and GitHub

Tanzanian HCES Analysis and TFNC Training

Author

Liberty Mlambo

1 Introduction to R, RStudio, Git and GitHub (Week 1)

1.1 R and Rstudio

  • R is a free software environment for statistical computing and graphics
  • Rstudio is a integrated development environment (IDE) for R and Python.
    • open source and commercial editions (Windows, Mac, and Linux)

1.2 Rstudio (cont..)

  • console for direct code execution

  • syntax-highlighting editor

  • tools for plotting

  • viewing history

  • managing your workspace

1.3 GitHub (and GIT)

1.4 Git

1.4.1 Git

Open source
Tracks file changes
Branch based non-linear workflows (we can all work at the same time)
Rstudio IDE intergration
Speed of work (for quick homework assistance)
Local environment

1.5 GitHub

GitHub is a web-based interface that uses Git, to let multiple people work and make changes on a project concurrently

1.5.1 Fremium Repository based

  • Repository based (Projects)

1.5.2 Built-in security

1.5.3 File History Tracking

1.5.4 Unlimited Public/ Private Repositories

1.5.5 Track issues and task progress

1.5.6 Track issues and task progress

1.5.7 Lessons learnt

Cloud storage and collaboration very important and a key focus area
Reproducibility through version tracking is fundamental
Choose tools carefully to avoid security lapses
CTRL + ALT + SHIFT+F (Git Urgent)

1.6 Practical Demonstration

1.6.1 Practical Assumptions

  • Computer (Mac, Windows, Linux, etc..) with administrative privileges
  • Software download and installation experience

1.6.2 Practical Requirements

  • GitHub account
  • Rstudio
  • Git

1.7 Exercises

1.7.1 Exercises 1

Activity Description
1.1 GitHub sign-up GitHub signup
1.2 R download and installation R download
1.3 Rstudio download and installation Rstudio
1.4 Git download and installation Git

1.7.2 Exercises 2 - RStudio and Git connection (optional)

Action Command
In Rstudio console type usethis::create_github_token()
In your github account generate and copy token
In Rstudio console type gitcreds::gitcreds_set()
In Rstudio console paste token
In Rstudio terminal git config user.name "YourGitHubUsername"
In Rstudio terminal git config user.email "YourGitHubEmail@here.com"

2 Linking GitHub and R (Week 2)

2.1 Week 1 Recap

  • Last week we introduced Git, GitHub, R and RStudio.
  • Exercise 1: – Creating GitHub credential – Downloading and Installing R, RStudio and Git
  • Exercise 2 (Optional) - Linking GitHub and R

2.2 Configuring Git from RStduio (Exercise 2)

First configure Git by telling it who you are. In Rstudio Terminal run:

2.3 GitHub workflow

3 Additional Resources

3.1 Additional Resources